import java.util.Scanner;

public class Demo4 {

    public volatile static int flag = 0;

    public static void main(String[] args) {

        Thread t1 = new Thread(() -> {

            while (flag == 0) {

//                try {
//                    Thread.sleep(1);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
            }
            System.out.println("t1 jieshu");

        });

        Thread t2 = new Thread(() -> {

            Scanner sc = new Scanner(System.in);
            System.out.println("请输入任意数字结束 t1 线程");
            flag = sc.nextInt();
        });

        t1.start();
        t2.start();
    }
}
